package Offer.offer;

/**
 * 二进制中1的个数
 * @author leiwenkang
 * @date 2020/4/6
 */
public class Test10二进制中1的个数 {
    public int getNumOf1(int num) {
        int count = 0;
        while (num != 0) {
            count++;
            num = num & (num - 1);
        }
        return count;
    }
}
